<?php /**
*DomainObjectCollection Collection for holding objects of type DomainObject.
*
*@package Business
*@author Garry Willits
*@copyright 2005
*@version 1.1
*/

class DomainObjectCollection extends Collection{

/**
*wraps parent class
*@param ViewHelper
*/
public function __construct( $object=null ){
if( isset($object) ){
    if( ! $object instanceof DomainObject ){
      throw new Exception( "This collection only holds objects of type Domain Object ");
    }
}
parent::__construct( $object );
}
/**
*Add element to collection
*@param ViewHelper
*@param int
*/
public function addElement( DomainObject $object , $key=null){
    if( !isset($key) ){
    $this->doAddElement ( $object);
    }
    else {
    $this->doAddElementByKey ( $object , $key );
    }
}

/**
 * find a given domain object
 * @param unknown_type $oid
 * @return unknown
 */
public function find($oid){
    if( is_array( $this->collection )){
	        foreach( $this->collection as $check ){
            if( $check->oid === $oid){
            return $object;
            }
    	}
    }
    return false;
}

}

?>
